911B - Two Cakes - CodeForces Solution


binary search brute force implementation *1200

Please click on ads to support us..

Python Code:

n,a,b=map(int,input().split())
print(max(min(a//i,b//(n-i)) for i in range(1,n)))

C++ Code:

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int n,a,b;

bool ok(int mid)
{
    if(a/mid + b/mid >= n)
        return true;
    return false;
}

int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);


    cin>>n>>a>>b;

    int l=1,r=min(a,b);

    while(l<r)
    {
        int mid = (l+r+1)/2;
        if(ok(mid))
            l = mid;
        else
            r = mid-1;
    }

    cout<<r;


    return 0;
}


Comments

Submit
0 Comments
More Questions

137C - History
1443C - The Delivery Dilemma
6C - Alice Bob and Chocolate
1077C - Good Array
285B - Find Marble
6A - Triangle
1729A - Two Elevators
1729B - Decode String
1729C - Jumping on Tiles
1729E - Guess the Cycle Size
553B - Kyoya and Permutation
1729D - Friends and the Restaurant
1606C - Banknotes
580C - Kefa and Park
342A - Xenia and Divisors
1033A - King Escape
39D - Cubical Planet
1453A - Cancel the Trains
645A - Amity Assessment
1144A - Diverse Strings
1553B - Reverse String
1073A - Diverse Substring
630N - Forecast
312B - Archer
34D - Road Map
630I - Parking Lot
160B - Unlucky Ticket
371B - Fox Dividing Cheese
584B - Kolya and Tanya
137B - Permutation